<template>
    <div class="app-container">
        <!-- 查询模块 -->
        <div class="formDiv">
            <el-form ref="form" :inline="true" label-width="140px">
                <el-row>
                    <el-col :span="6">
                        <el-form-item label="支付状态">
                            <el-select placeholder="请选择" v-model="form.payStatus">
                                <el-option
                                v-for="item in payOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="签约人姓名">
                            <el-input v-model="form.username"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="签约人手机号">
                            <el-input v-model="form.phone"></el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span="6">
                        <el-form-item label="分公司">
                            <el-select placeholder="请选择" v-model="form.companyId">
                                <el-option
                                v-for="item in officeOption"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="审核状态">
                            <el-select placeholder="请选择" v-model="form.handleStatus">
                                <el-option
                                v-for="item in handleOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="订单号">
                            <el-input v-model="form.orderSn"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item>
                            <el-button style="margin-left:60px" type="primary" @click="searchFn">查询</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <!-- 主页列表 -->
        <div class="listDiv" v-loading="tableLoading">
            <!-- table列表 -->
            <el-table
                :data="tableData"
                class="tableData"
                style="width: 100%">
                <el-table-column
                    prop="companyName"
                    label="所属分公司"
                >
                </el-table-column>
                <el-table-column
                    prop="orderSn"
                    label="订单号"
                >
                </el-table-column>
                <el-table-column
                    prop="username"
                    label="姓名"
                >
                </el-table-column>
                <el-table-column
                    prop="phone"
                    label="手机号"
                >
                </el-table-column>
                <el-table-column
                    label="签约身份"
                >
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.roleId | roleType}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    label="证件类型"
                >
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.identityType | cardType}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="identity"
                    label="证件号码"
                >
                </el-table-column>
                <el-table-column
                    prop="refereeUser"
                    label="团队"
                >
                </el-table-column>
                <el-table-column
                    label="账号类型"
                >
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.accountType | accType}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    label="审核状态"
                >
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.handleStatus | handleStatusType}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="price"
                    label="实付金额"
                >
                </el-table-column>
                <el-table-column
                    prop="orderTime"
                    label="支付时间"
                >
                </el-table-column>
                <el-table-column
                    label="支付状态"
                >
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.payStatus | payStatusType}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    fixed="right"
                    label="操作"
                    width="100"
                >
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="reviewFn(scope.row)">审核</el-button>
                    <el-button type="text" @click="toRoutes('designerAuditInfo',scope.row.id)" size="small">详情</el-button>
                </template>
                </el-table-column>
            </el-table>
            <!-- 审核弹窗 -->
            <el-dialog
            title="审核"
            :visible.sync="dialogVisible"
            :before-close="closeFn"
            width="468px">
                 <el-form ref="reviewForm" :inline="true" label-width="140px">
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="手机号">
                                <span class="borderNone">{{reviewList.phone}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="开户银行">
                                <span class="borderNone"></span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="银行账户">

                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="开户银行">

                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="审核">
                                <el-radio v-model="radio" label="1">通过</el-radio>
                                <el-radio v-model="radio" label="2">不通过</el-radio>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="审核理由">
                                <el-input></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                 </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="closeFn()">取 消</el-button>
                    <el-button type="primary" @click="submitFn()">确 定</el-button>
                </span>
            </el-dialog>
            <!-- 分页 -->
            <div class="pagesCon">
                <div>
                    <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="listForm.pageNum"
                    :page-sizes="page_sizes"
                    :page-size="listForm.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="page_totals">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { listMmkElectronics} from '@/api/designerAudit'
import { companyList } from '@/api/branchOfficeDropDown'
export default {
    name:"designerAuditIndex",
    data(){
        return {
            dialogVisible:false,
            tableLoading:true,
            date:"",
            value1:"",
            radio:"1",
            tableData: [],
            page_sizes:[10,30,50,100],
            page_totals:60,
            listForm:{
                pageNum: 1,
                pageSize:10
            },
            payOptions:[],
            officeOption:[],
            handleOptions:[],
            form:{
                payStatus:null,
                username:null,
                phone:null,
                companyId:null,
                handleStatus:null,
                orderSn:null,
                pageNum: 1,
                pageSize:10
            },
            reviewList:{}
        }
    },
    filters:{
        roleType(e){
            return window.helper.roleFn(String(e))
        },
        cardType(e){
            return window.helper.cardType(String(e))
        },
        accType(e){
            return window.helper.accountType(String(e))
        },
        payStatusType(e){
            return window.helper.payStatusType(String(e))
        },
        handleStatusType(e){
            return window.helper.handleStatusType(String(e))
        }
    },
    mounted(){
        this.getCompanyList()
        this.getList(this.listForm)
        //获取支付option
        this.payOptions = window.helper.payStatusType("listReturn")
        //获取审核option
        this.handleOptions = window.helper.handleStatusType("listReturn")
    },
    methods:{
        //获取分公司列表
        getCompanyList(){
            companyList().then(res =>{
                let resData = res.data.data
                let newData = [];
                resData.forEach(e => {
                    newData.push({
                        value:e.id,
                        label:e.name
                    })
                });
                this.officeOption = newData
            })
            .catch(error =>{
                this.$message.error(error);
            })
        },
        //成功状态弹窗
        succStatus(txt){
            this.$message({
                message: txt+'成功',
                type: 'success'
            });
        },
        //失败状态弹窗
        errorStatus(txt){
            this.$message.error(txt+'失败');
        },
        //查询
        searchFn(){
            this.getList(this.form)
        },
        // 路由跳转
        toRoutes(e,userId) {
            let route = {name:e,query:{userId:userId}}
            this.$router.push(route)
        },
        //列表数据获取
        getList(e){
            this.tableLoading = true
            let datas = e
            listMmkElectronics(datas).then(res => {
                if(!res.data.code){
                    this.tableData = res.data.data.electronicDTOS
                    this.page_totals = res.data.data.count
                }else{
                    this.$message.error("数据接口访问失败");
                }
                this.tableLoading = false
            })
            .catch(error =>{
                this.$message.error(error);
            })
        },
        reviewFn(e){
            this.dialogVisible = true
            this.reviewList = e
        },
        //弹窗关闭
        closeFn(){
            this.dialogVisible = false
        },
        // 弹窗内容提交
        submitFn(){
            this.dialogVisible = false
        },
        //删除
        deleteFn(e){
            let datas = {
                id:e
            }
            this.$confirm('删除该条数据, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                deleteData(datas).then(res =>{
                    if(!res.data.code){
                        this.succStatus("删除")
                        this.getList(this.listForm)
                    }else{
                        this.$message.error("数据接口访问失败");
                    }
                })
                .catch(error =>{
                    this.$message.error(error);
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        //改变页面条数
        handleSizeChange(val) {
            this.form.pageSize = val
            this.getList(this.form)
        },
        //选择页数
        handleCurrentChange(val) {
            this.form.pageNum = val
            this.getList(this.form)
        },
    }
}
</script>
<style scoped>
/* 分页 */
.pagesCon{height: 40px;margin-top: 20px}
.pagesCon>div{float: right;}
</style>
